                                        Appendix E

                               A Skeletal Cold Start Loader



                                  ;this is a sample cold start loader, which, when
                                  ;modified
                                  ;resides on track 00, sector 01 (the first sector on the
                                  ;diskette). we assume that the controller has loaded
                                  ;this sector into memory upon system start-up (this
                                  ;program can be keyed-in, or can exist in read-only
                                  ;memory
                                  ;beyond the address space of the cp/m version you are
                                  ;running). the cold start loader brings the cp/m system
                                  ;into memory at "loadp" (3400h + "bias"). in a 20k
                                  ;memory system, the value of "bias" is 000h, with
                                  ;large
                                  ;values for increased memory sizes (see section 2).
                                  ;after
                                  ;loading the cp/m system, the cold start loader
                                  ;branches
                                  ;to the "boot" entry point of the bios, which beings at
                                  ;"bios" + "bias". the cold start loader is not used un-
                                  ;til the system is powered up again, as long as the bios
                                  ;is not overwritten. the origin is assumed at 0000h, and
                                  ;must be changed if the controller brings the cold start
                                  ;loader into another area, or if a read-only memory
                                  ;area
                                  ;is used.

0000                                        org 0                  ;base of ram in
                                                                   ;cp/m

0014 =                            msize     equ 20                 ;min mem size in
                                                                   ;kbytes
0000 =                            bias      equ (msize-20)*1024    ;offset from 20k
                                                                   ;system
3400 =                            ccp       equ 3400h+bias         ;base of the ccp
4a00 =                            bios      equ ccp+1600h          ;base of the bios
0300 =                            biosl     equ 0300h              ;length of the bios
4a00 =                            boot      equ bios  
1900 =                            size      equ bios+biosl-ccp     ;size of cp/m
                                                                   ;system
0032 =                            sects     equ size/128           ;# of sectors to load

                                  ;         begin the load operation

                                  cold:
0000 010200                                 lxi  b,2               ;b=0, c=sector 2
0003 1632                                   mvi  d,sects           ;d=# sectors to
                                                                   ;load
0005 210034                                 lxi  h,ccp             ;base transfer
                                                                   ;address
                                  lsect:    ;load the next sector

                                  ;         insert inline code at this point to
                                  ;         read one 128 byte sector from the
                                  ;         track given in register b, sector
                                  ;         given in register c,
                                  ;         into the address given by <hl>
                                  ;branch to location "cold" if a read error occurs
                                  ;
                                  ;
                                  ;              user supplied read operation goes
                                  ;              here...
                                  ;
                                  ;

0008 c36b00                                 jmp past$patch         ;remove this
                                                                   ;when patched
000b                                        ds   60h

                                  past$patch:
                                  ;go to next sector if load is incomplete
006b 15                                     dcr  d                 ;sects=sects-1
006c ca004a                                 jz   boot              ;head for the bios

                                  ;         more sectors to load
                                  ;
                                  ;we aren't using a stack, so use <sp> as scratch
                                  ;register
                                  ;         to hold the load address increment

006f 318000                                 lxi  sp,128            ;128 bytes per
                                                                   ;sector
0072 39                                     dad  sp                ;<hl> = <hl> +
                                                                   128
0073 0c                                     inr  c                 ;sector=sector + 1
0074 79                                     mov  a,c 
0075 felb                                   cpi  27                ;last sector of
                                                                   ;track?
0077 da0800                                 jc   lsect             ;no, go read
                                                                   ;another

                                  ;end of track, increment to next track

007a 0e01                                   mvi  c,l               ;sector = 1
007c 04                                     inr  b                 ;track = track + 1
007d c30800                                 jmp  lsect             ;for another group
0080                                        end                    ;of boot loader


.nx appf
